package cn.edu.ncc.controller;

import cn.edu.ncc.Student;
import cn.edu.ncc.service.impl.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class C1 {
  @Autowired
  IStudentService iStudentService;
  @RequestMapping(value = "/test1")
  public ModelAndView getStudentName(){
    ModelAndView modelAndView = new ModelAndView();
    List<Student> list = iStudentService.findAll();
    for(Student s:list){
      if (s.getSid().equals("19302210")){
        modelAndView.addObject("name",s.getSname());
      }
    }
    modelAndView.setViewName("show_student_name");
    return modelAndView;
  }
}